#include "Detail.h"
#include "Common/Common.h"
#include "Core/Core.h"
#include "Physics/Colliders/ICollider.h"
#include "Physics/Shapes/IShape.h"
#include "Logic/PhysicsDebugDrawer.h"

Detail::Detail( std::string id ) :
	Part( id ),
	_body( 0 )
{
}

Detail::~Detail( )
{
}

void Detail::SetBody( physics::IBody* body )
{
	_body = body;
}

physics::IBody* Detail::GetBody( ) const
{
	return _body;
}

void Detail::PerformAction( const Action& )
{
}

void Detail::Update( float )
{

}

void Detail::Draw( ) const
{
	PhysicsDebugDrawer* drawer = new PhysicsDebugDrawer(core::Color::GREEN);
	drawer->SetPosition(_body->GetPos());

	for(
		IteratorPtr<const physics::ICollider*> iter(_body->GetColliders()->GetIterator());
		!iter->IsEnd();
		iter->Next() )
	{
		//const physics::ICollider* collider = iter->Current();
		//const physics::IShape* shape = collider->GetShape();

		//shape->Accept(drawer);

		const core::Texture* tex = core::Renderer::GetTextureStore().GetTexture("Models/tex.png");
		core::Renderer::DrawTexture(tex, _body->GetPos(), 1.0f, 1.0f);
	}

	delete drawer;
//	core::Renderer::DrawPolygon(  );
}
